# Maintainer: fossdd <fossdd@pwned.life>
pkgname=py3-awscrt
pkgver=0.23.0
pkgrel=0
pkgdesc="Python bindings for the AWS Common Runtime"
url="https://github.com/awslabs/aws-crt-python"
# s390x: big endian is explicitly unsupported
arch="all !s390x"
license="Apache-2.0"
# use the cpp one to just pull the aws stack
makedepends="
	aws-crt-cpp-dev
	openssl-dev
	py3-gpep517
	py3-setuptools
	py3-wheel
	python3-dev
	samurai
	"
checkdepends="py3-websockets"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/awslabs/aws-crt-python/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/aws-crt-python-$pkgver"
options="net" # tests need internet

case "$CARCH" in
arm*|aarch64|ppc64le|loongarch64)
	# too slow at running tests / fix later
	options="$options !check"
	;;
esac
prepare() {
	default_prepare

	# by default it's just 1.0.0.dev0
	echo "__version__ = '$pkgver'" >> awscrt/__init__.py

	# dynlink
	sed -i '/:lib/d' setup.py
}

build() {
	export AWS_CRT_BUILD_USE_SYSTEM_LIBCRYPTO=1
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m unittest discover test
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
94a02c45471a792e8ebce4ed114dc88b8ea1cb8cf3cca6264f2c9c4ea8ab74879e99870309d000333fde2972afb86ad48640904e2e4c244d9906e90710cf102c  py3-awscrt-0.23.0.tar.gz
"
